AVIF file structure parser (demuxer)
Get AV1 payload and the alpha channel metadata out of AVIF image files.
This is a minimal ISOBMFF/MIAF and AV1 OBU parser. It is a fork of Mozilla's MP4 parser used in Firefox, so it's designed to be robust and safely handle untrusted data. This crate is written entirely in safe Rust code.
The parser is compatible with files supported by libavif, Chrome 85 and Firefox 81a. It parses all files in the AOM test suite.
This crate doesn't include an AV1 decoder. To display the pixels you will additionally need dav1d or libaom (full decoder example).
Usage from Rust
It takes io::Read
, so you can use any readable input, such as a byte slice (vec.as_slice()
), or a File
wrapped in BufReader
, etc.
let data = read_avif?;
av1_decode?;
if let Some = &data.alpha_item
if data.premultiplied_alpha
Usage from C
Install Rust 1.68 or later, preferably via rustup, and run:
It will build ./target/release/libavif_parse.a
(or avif_parse.lib
on Windows). Link it with your project.
Cargo supports cross-compilation, so you can easily build it for other platforms (e.g. iOS).
= ;
if
;
avif_data_t data